package com.ruoyi.web.controller.match;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.squadweb.domain.FactionRanking;
import com.ruoyi.squadweb.service.IFactionRankingService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 战队排名Controller
 *
 * @author ruoyi
 * @date 2024-07-19
 */
@RestController
@RequestMapping("/system/ranking")
public class FactionRankingController extends BaseController
{
    @Autowired
    private IFactionRankingService factionRankingService;


    @GetMapping("/team/member/info")
    public AjaxResult getTeamMemberInfo(String teamId)
    {

        List<Map<String,String>> list= factionRankingService.getTeamMemberInfo(teamId);
        return AjaxResult.success(list);
    }

    /**
     * 查询战队排名列表
     */
    @GetMapping("/getInfo")
    public TableDataInfo getInfo(FactionRanking factionRanking)
    {
        List<FactionRanking> list = factionRankingService.selectFactionRankingList(factionRanking);
        return getDataTable(list);
    }



    /**
     * 查询战队排名列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FactionRanking factionRanking)
    {
        startPage();
        List<FactionRanking> list = factionRankingService.selectFactionRankingList(factionRanking);
        return getDataTable(list);
    }

    /**
     * 导出战队排名列表
     */
    @Log(title = "战队排名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FactionRanking factionRanking)
    {
        List<FactionRanking> list = factionRankingService.selectFactionRankingList(factionRanking);
        ExcelUtil<FactionRanking> util = new ExcelUtil<FactionRanking>(FactionRanking.class);
        util.exportExcel(response, list, "战队排名数据");
    }

    /**
     * 获取战队排名详细信息
     */
    @GetMapping(value = "/{teamId}")
    public AjaxResult getInfo(@PathVariable("teamId") String teamId)
    {
        return success(factionRankingService.selectFactionRankingByTeamId(teamId));
    }

    /**
     * 新增战队排名
     */
    @Log(title = "战队排名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FactionRanking factionRanking)
    {
        return toAjax(factionRankingService.insertFactionRanking(factionRanking));
    }

    /**
     * 修改战队排名
     */
    @Log(title = "战队排名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FactionRanking factionRanking)
    {
        return toAjax(factionRankingService.updateFactionRanking(factionRanking));
    }

    /**
     * 删除战队排名
     */
    @Log(title = "战队排名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{teamIds}")
    public AjaxResult remove(@PathVariable Long[] teamIds)
    {
        return toAjax(factionRankingService.deleteFactionRankingByTeamIds(teamIds));
    }
}
